<?php 
/* 定义属性 */
define ("CONfilename", "../../config/set.php");
define ("DDUDB","../../class/db.class.php");
define ("LOADINDEX","../../class/load.class.php");
session_start();
/* 為系統作配置準備，方便以後系統引用數據庫 */
require_once(CONfilename);/*讀設置*/
require_once(DDUDB);/* 載入數據庫模塊 */
require_once(LOADINDEX);/* 載入引導模塊 */
/*下面建立數據連接，添加數據庫模塊到變量，使db變量可以直接控制sql。  */
$db = new CDB();
$ckb = new ckb();
$MEMBER = new member();
if (!is_selog()){
	$now_user = '';
}else {
	$now_user = $_SESSION['uid'];
}
$now_em = $MEMBER->getnickname($now_user);
$content =array(3);
$showhtml = "";
/* 函数 */
function deletecontent($cn,$sn) {
	global $db;
	$db->ExeQuerySql("SELECT * FROM `cu_glxq` WHERE  contactnumber='$cn' AND time='$sn'");
	if ($db->FetchRow()){
		$db->ExeSql("delete from `cu_glxq` where contactnumber='$cn' AND time='$sn'");
		return  "已删除联系电话为".$cn."的工单！".'<a href="javascript:history.back();">点击返回</a>';
	};
}
function viewcontent($cn,$sn) {
	global $db;
	global $content;
	$db->ExeQuerySql("SELECT * FROM `cu_qcxq` WHERE  checknumber='$cn' AND sn='$sn'");
	if ($db->FetchRow()){
		$content[1]=$db->Get('isop');
		$content[2]=$db->Get('optext');
		$content[3]=$db->Get('isplan');
		$content[4]=$db->Get('plantext');
		$content[5]=$db->Get('isrepay');
		$content[6]=$db->Get('repaytext');
		$content[7]=$db->Get('iscommunicate');
		$content[8]=$db->Get('communicatetext');
		$content[9]=$db->Get('type');
		$content[10]=$db->Get('clname');
		$content[11]=$db->Get('link');
		$content[12]=$sn;
		$content[13]=$cn;
		$content[14]=$db->Get('appraise');
		$content[15]=$db->Get('cltime');
		$content[16]=$db->Get('hwyid');
		return  $content;
	};
}
function showinprogress($cn,$sn) {
	global $now_em;
	global $content;
	$showcontent='<div id="gdc"><div class="vbr">工單處理</div><form method="post" action="viewgdxq.php?action=submitgdnr&cn='.$cn.'&sn='.$sn.'"><table>
  	<tr>
    	<td>工单处理人：</td>
    	<td><input type="text" name="chuliren" id="chuliren"  value="'.$now_em.'"/></td>
    	<td>处理状态：</td>
    	<td><select name="gdlb" id="gdlb"><option value="正在处理">正在处理</option><option value="稍后跟踪">稍后跟踪</option><option value="正在查核">正在查核</option><option value="正在联系">正在联系</option><option value="归档">归档</option><option value="直接归档">直接归档</option></select></td>
	 </tr>
 	 <tr>
  	  	<td colspan="4">归档内容：<br><textarea name="archivecontent" id="archivecontent" value="'.$content[4].'"></textarea></td>
  	</tr>
 	 <tr>
  	  	<td colspan="4"><input name="reg-submit" value="提交" type="submit" /></td>
  	</tr>
	</table>
	</form></div>';
	$html='<div>'.$showcontent.'</div>';
	return $html;
}
function submitgdnr($posti,$cn,$sn) {
	global $db;
	$db->ExeQuerySql("SELECT * FROM `cu_qcxq` WHERE  checknumber='$cn' AND sn='$sn'");
	if ($db->FetchRow()){
		$db->ExeSql("update `cu_glxq` set ctrlman='$posti[chuliren]',isend='$posti[gdlb]',endtime=now(),archivecontent='$posti[archivecontent]' where contactnumber='$cn' AND time='$time'");
	};
}
function getqcctrllink($cn,$sn) {
	return '（<a href="viewqcxq.php?action=progress&cn='.$cn.'&sn='.$sn.'" class="gdhref">处理</a>）';
}
/* 判断式 */
if (!empty($_GET['action'])){
	switch ($_GET['action']) {
		case 'delete':
			$content = deletecontent($_GET['cn'], $_GET['sn']);
		break;
		case 'progress':
			$content = viewcontent($_GET['cn'], $_GET['sn']);
			$showhtml = showinprogress($_GET['cn'], $_GET['sn']);
		break;
		case 'submitgdnr':
			submitgdnr($_POST,$_GET['cn'],$_GET['sn']);
			$content = viewcontent($_GET['cn'], $_GET['sn']);
		break;
	}
}elseif(!empty($_GET['cn']) && !empty($_GET['sn'])){
	$content = viewcontent($_GET['cn'], $_GET['sn']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>联系电话：<?php if (!empty($_GET['cn'])) {echo $_GET['cn'];}?>的工单查看与处理</title>
<link href="../../css/pluin_viewgd.css" rel="stylesheet" type="text/css" />
</head>

<body class="fff">
<div id="gdc">
<div class="vbr">质检明細</div>
<table class="gdl"  border="1px" cellspacing="0px" style="border-collapse:collapse">
  <tr>
  </tr>
  <tr>
    <th>电话号码：</th>
    <td><?php echo $content[13]?></td>
    <th>通话序号:</th>
    <td><?php echo $content[12]?></td>
    <th>呼叫工号：</th>
    <td><?php echo $content[16]?></td>
    <th>监听人员：</th>
    <td><?php echo $content[10]?></td>
  </tr>
  <tr>
  	<th>录音类型：</th>
  	<td><?php echo $content[9]?></td>
  	<th>是否释放:</th>
  	<td><?php echo $content[7]?></td>
  	<th>监听时间:</th>
  	<td><?php echo $content[15]?></td>
  	<td></td>
  	<td></td>
  </tr>
  <tr>
  	<th>第一步：吸引</th>
  	<th><?php echo $content[1]?></th>
  	<th>第二步：以附送的形式说套餐</th>
  	<th><?php echo $content[3]?></th>
  	<th>第三步：话费返还规则</th>
  	<th><?php echo $content[5]?></th>
  	<th>第四步：深化客户的需求</th>
  	<th><?php echo $content[7]?></th>
  </tr>
  <tr>
  	<th>时间段：</th>
  	<th><?php echo $content[2]?></th>
  	<th>时间段：</th>
  	<th><?php echo $content[4]?></th>
  	<th>时间段：</th>
  	<th><?php echo $content[6]?></th>
  	<th>时间段：</th>
  	<th><?php echo $content[8]?></th>
  </tr>
  <tr>
  	<th>录音內容：</th>
  	<td colspan="7"><a href="<?php echo $content[11]?>" target="view_window">连接至录音音频</a></td>
  </tr>
</table>
<div class="vbr">监听情况<?php if ($MEMBER->getroot($now_user)>2){}?></div>
<table class="gdl"  border="1px" cellspacing="0px" style="border-collapse:collapse">
	<tr>
		<th>质检评论內容：</th>
	</tr>
	<tr>
		<td><?php echo $content[14]?></td>
	</tr>
</table>
</div>
<?php echo $showhtml?>
</body>
</html>
<?php
?>

